<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.hz.util.ParamUtil"%>
<%@page import="com.hz.control.UserControl"%>
<%@page import="com.hz.model.User"%>
<%@page import="com.hz.model.Hobby"%>
<%@page import="com.hz.model.ParamSpecial"%>
<%@page import="com.hz.model.ParamDepartment"%>
<%@page import="com.hz.control.ParamDepartmentManager"%>
<%@page import="com.hz.control.ParamSpecialManage"%>
<%@page import="com.hz.control.HobbyControl"%>
<%@page import="com.hz.util.GradeList"%>
<%@page import="com.hz.model.Province"%>
<!DOCTYPE HTML>
<html>
  <head>
    <title>个人信息</title>
    <meta charset="utf-8"/>
	<link rel="stylesheet" type="text/css" href="../../css/info.css"/>
	<script type="text/javascript" src="../../js/core.js"></script>
	<script type="text/javascript" src="../common/js/jquery.js"></script>
	<script type="text/javascript" src="../common/js/calendar.js"></script>
	<script type="text/javascript" src="../common/js/getMajors.js"></script>
<script language=javascript>

 function getCheckbox(checkboxname)
 {
  var obj=document.getElementsByName(checkboxname);
  var strsel = "";
  for (var i=0;i<=obj.length-1;i++)
  {
     if (obj[i].checked&&obj[i].value!="")
     {
    strsel = "@"+strsel + obj[i].value+"@";
     }
     //strsel=strsel+"@";
  }
  //alert(strsel)
  document.getElementById("setValue").value=strsel;//将选中的值赋给hidden
  //alert(document.getElementById("setValue").value);
  }
</script>
<script type="text/javascript">
        var popUpWin = 0;
        function PopUpWindow(URLStr, left, top, width, height, newWin, scrollbars) {
            if (typeof (newWin) == "undefined")
                newWin = false;

            if (typeof (left) == "undefined")
                left = 100;

            if (typeof (top) == "undefined")
                top = 0;

            if (typeof (width) == "undefined")
                width = 800;

            if (typeof (height) == "undefined")
                height = 760;

            if (newWin) {
                open(URLStr, '', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=' + scrollbars + ',resizable=yes,copyhistory=yes,width=' + width + ',height=' + height + ',left=' + left + ', top=' + top + ',screenX=' + left + ',screenY=' + top + '');
                return;
            }
            if (typeof (scrollbars) == "undefined") {
                scrollbars = 0;
            }
            if (popUpWin) {
                if (!popUpWin.closed) popUpWin.close();
            }
            popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=' + scrollbars + ',resizable=yes,copyhistory=yes,width=' + width + ',height=' + height + ',left=' + left + ', top=' + top + ',screenX=' + left + ',screenY=' + top + '');
            popUpWin.focus();
        }
</script>
  </head>
  <body>
    <%    
          request.setCharacterEncoding("utf-8");
          //User cu = (User)session.getAttribute("user");//当前用户
          int uid = ParamUtil.getInt(request,"userid",(Integer)session.getAttribute("userid"));
          User u = UserControl.getUserInformation(uid);//所显示的用户
          session.setAttribute("serachdid",u.getMajorId());
         
         
     %>
   <form onsubmit=" return getCheckbox('hobbies');" action="info_update_do.jsp?uid=<%=uid %>" method="post" name="form">
   <fieldset>
   <legend class='title'>个人信息修改<span><a href ="userinfo.jsp">返回</a></span></legend>
    <table class='sec'>
   <tr><td width='200'>姓名</td><td><input type="text"value="<%=u.getRealname() %>" name="realname" /></td></tr>
   <tr><td>学号</td><td><input type="text"value="<%=u.getStuNum() %>" name="stuNum" readonly/></td></tr>
   <tr><td>学历</td><td><input type="radio" name="stuLevel"<%if(u.getStuLevel()==0)out.print("checked");%> value="0"/>本科生
   <input type="radio" name="stuLevel" <%if(u.getStuLevel()==1)out.print("checked");%> value="1"/>研究生</td></tr>
   <tr><td>性别：</td><td><input type="radio" <%if(u.getSex()==0)out.print("checked");%> name="sex" value="0"/>女
   <input type="radio" <%if(u.getSex()==1)out.print("checked");%> name="sex" value="1"/>男
   </td></tr>
   <tr><td>QQ</td><td><input type="text"value="<%=u.getQq() %>" name="qq"/></td></tr>
   <tr><td>E-mail</td><td><input type="text"value="<%=u.getEmail() %>" name="email"/></td></tr>
   <tr>
   <td>学院：</td><td><select name="departmentId" id="departmentId">
	<% 
	    ArrayList<ParamDepartment> pd = ParamDepartmentManager.getAllDepartment(0);
	    for(int i=0;i<pd.size();i++){
	        ParamDepartment p = pd.get(i);  
	%>
	<option value="<%=p.getId() %>" <%if(p.getId()==u.getDepartmentId()){out.print("selected='selected'");} %>><%=p.getDepartmentName() %></option>
	<%}System.out.print(u.getDepartmentId()); %>
	</select></td></tr>
	<tr>
	<td>专业:</td><td><select name="majorId" id="majorId"></select></td>
	</tr>
   <tr><td>年级</td><td><select name="grade">
	<%
	    int grade[] = GradeList.getGradeList();
	    for(int g:grade){
	 %>
	<option value="<%=g %>"<%if(u.getGrade()==g)out.print("selected='selected'"); %>><%=g%></option>
	<%} %>
</select></td></tr>
   <tr><td>出生日期</td><td><input name="birthday"type="text" value="<%=u.getBirthday()%>" id="range_date" onclick="new Calendar(1980, 2020).show(this);"  size="10" maxlength="10" readonly="readonly"/></td></tr>
   <tr><td>籍贯</td><td><select name="birthPlace">
<%  String provinces[]=Province.getAllProvinces();
    for (String p : provinces) {
    %>
    <option value="<%=p%>" <%if(p.equals(u.getBirthPlace()))out.print("selected='selected'"); %>><%=p%></option>
<%} %>
</select></td></tr>
   <tr><td>志愿者编号</td><td><input type="text"value="<%=u.getVolunteerNo() %>" name="volNo" readonly/></td></tr>
   <tr><td>志愿者星级</td><td><input type="text"value="<%=u.getVolunteerLev() %>" name="volLev" readonly/></td></tr>
   <tr><td>身份证号</td><td><input type="text"value="<%=u.getIdCard() %>" name="idCard"/></td></tr>
   <tr><td>志愿者服务类型</td><td>
   <%
      Collection<Hobby> hs = HobbyControl.getAllHobbies();
      boolean flag=false;
      String[] uh = new String[100];
      if(u.getHobby()!=null&&!u.getHobby().equals("")){
    	  flag = true;
       uh = u.getHobby().split("@");
      Arrays.sort(uh);}
      Iterator<Hobby> it = hs.iterator();
      while(it.hasNext()){
        Hobby h=it.next();
 %>
<input type="checkbox" name="hobbies" value="<%=h.getId()%>" <%if(flag){if(Arrays.binarySearch(uh,""+h.getId())>0) out.print("checked");} %>><%=h.getHobbyName() %>
<%}%>
<input type="hidden" id="setValue" name="hobby">
   </td></tr>
   <tr><td>曾获荣誉</td><td><textarea style='width:450px;' name="award"><%=u.getAward() %></textarea></td></tr>
   <tr><td>志愿者经历</td><td><textarea style='width:450px;' name="volunteerExp"><%=u.getVolunteerExp() %></textarea></td></tr>
   <tr><td>
<input type="submit" value="提交" ></td>
<td><input type="reset" value="还原"></td></tr>
   </table>
   </fieldset>
   </form>
  </body>
</html>
